<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<title></title>
	<link rel="stylesheet" href="">
	<style>
		.classA{
			color: #f24;
		}
		.classB{
			color: gray;
		}
		.classC{
			color: pink;
		}
		.classD{
			color: blue;
		}
	</style>
</head>
<body>
<script src='http://cdn.jsdelivr.net/vue/1.0.26/vue.js'></script>
<script src='https://cdn.jsdelivr.net/vue.router/0.7.10/vue-router.min.js'></script>	
<div id="root">
	<div :class="classArray" @click = toggleClass('classC')>你好啊，李金文</div>
</div>
<script>
	var vm = new Vue({
		el : '#root',
		data : {
			classArray : ['classA','classB'],
		},
		methods : {
			toggleClass(cName){
				if(this.hasClass(cName).add){
					this.classArray.splice(this.hasClass(cName).id,1);
				}else{
					this.classArray.push(cName);
				}
			},
			hasClass(cName){//判断
				var bool = null;
				for(var i=0;i<this.classArray.length;i++){
					if(this.classArray[i]===cName){
						bool = {add:true,id:i};

					}else{
						bool = false;
					}
				}
				return bool;
			}
		}
	})
</script>
</body>
</html>